package com.mit.wx.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 2018/10/24 Create by 郭文梁
 * SetHeaderFilter
 * 过滤器：设置通用HttpHeader
 *
 * @author 郭文梁
 * @date 2018/10/24
 */
public class SetHeaderFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        if (response instanceof HttpServletResponse) {
            HttpServletResponse httpServletResponse = (HttpServletResponse) response;
            httpServletResponse.addHeader("X-Frame-Options", "SAMEORIGIN");
        }
        chain.doFilter(request, response);
    }

    @Override
    public void destroy() {

    }
}
